package com.tao.mytestgreendao.gen;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.github.yuweiguocn.library.greendao.MigrationHelper;

import org.greenrobot.greendao.database.Database;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

/**
 * reate by tao on{DATE}
 */
public class MyGreenDaoDevHelper extends DaoMaster.DevOpenHelper {
    Class[] classes;

    public MyGreenDaoDevHelper(Context context, String name, Class[] classes) {
        super(context, name);
        this.classes = classes;
        MigrationHelper.DEBUG=true;
    }


    public void onUpgrade(Database db, int oldVersion, int newVersion) {

        MigrationHelper.migrate(db, new MigrationHelper.ReCreateAllTableListener() {
            @Override
            public void onCreateAllTables(Database db, boolean ifNotExists) {
                DaoMaster.createAllTables(db, ifNotExists);
            }

            @Override
            public void onDropAllTables(Database db, boolean ifExists) {
                DaoMaster.dropAllTables(db, ifExists);
            }
        }, classes);
    }


}
